package com.caipos.actor.common.actors;

import com.caipos.actor.common.msg.KbActorMsg;

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Predicate;

public interface KbActorSystem {

    ScheduledExecutorService getScheduler();

    void createDispatcher(String dispatcherId, ExecutorService executor);

    void destroyDispatcher(String dispatcherId);

    KbActorRef getActor(KbActorId actorId);

    KbActorRef createRootActor(String dispatcherId, KbActorCreator creator);

    KbActorRef createChildActor(String dispatcherId, KbActorCreator creator, KbActorId parent);

    void tell(KbActorId target, KbActorMsg actorMsg);

    void tellWithHighPriority(KbActorId target, KbActorMsg actorMsg);

    void stop(KbActorRef actorRef);

    void stop(KbActorId actorId);

    void stop();

    void broadcastToChildren(KbActorId parent, KbActorMsg msg);

    void broadcastToChildren(KbActorId parent, KbActorMsg msg, boolean highPriority);

    void broadcastToChildren(KbActorId parent, Predicate<KbActorId> childFilter, KbActorMsg msg);

    List<KbActorId> filterChildren(KbActorId parent, Predicate<KbActorId> childFilter);
}
